package Demo6;

import java.io.*;

//复制
public class FileCopy {
    public static void main(String[] args)  {
        OutputStream os = null ;
        InputStream is = null;
        try {
            is=new FileInputStream("f:/TEST/a.txt");
            os = new FileOutputStream("f:/TEST/b.txt");
            int len;
            byte[] b = new byte[1024];
            while ((len=is.read(b))!=-1) {
                os.write(b,0,len);
            }
            System.out.println("写入完毕");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                os.close();
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
